<admintpl file="header" />
</head>
<body>
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li><a href="{:U('Groups/index')}">群组管理</a></li>
            <li><a href="{:U('Groups/add')}">添加群组</a></li>
            <li class="active"><a>关联设备</a></li>
        </ul>
        <if condition="I('param.area_type') eq 1">
        <form class="well form-search" method="post" action="{:U('Groups/add_device')}">
        <if condition="I('param.aid')">
        	<input type="hidden" name="aid" value="{:I('param.aid')}"/>
		<else />
	        <input type="hidden" name="area_name" value="{:I('param.area_name')}"/>
	        <input type="hidden" name="area_description" value="{:I('param.area_description')}"/>
	        <input type="hidden" name="area_locking" value="{:I('param.area_locking')}"/>
        </if>
      		<input type="hidden" name="source" value="{$source}"/>
      		<input type="hidden" name="area_type" value="{:I('param.area_type')}"/>
            设备类型：
            <select name="dtype" style="width: 150px;">
                <foreach name="dtype" item="vo">
                    <option <if condition="(I('param.dtype') eq $vo['id'])" >selected</if> value="{$vo.id}">{$vo.name}</option>
                </foreach>
            </select>
            查询类型：
            <select name="search" style="width: 100px;">
                <foreach name="search" item="vo">
                    <option <if condition="(I('param.search') eq $vo['id'])" >selected</if> value="{$vo.id}">{$vo.name}</option>
                </foreach>
            </select>
            查询内容：
            <input type="text" name="keyword" style="width: 150px;" value="{:I('param.keyword')}" placeholder="请输入查询内容...">
            <input type="submit" class="btn btn-primary" value="搜索" />
            <if condition="$count" >共查询到 {$count} 条数据</if>
        </form>
		<form action="{:U('Groups/'.$source.'_post')}" method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data">
        <if condition="I('param.aid')">
        	<input type="hidden" name="aid" value="{:I('param.aid')}"/>
		<else />
	        <input type="hidden" name="area_name" value="{:I('param.area_name')}"/>
	        <input type="hidden" name="area_description" value="{:I('param.area_description')}"/>
	        <input type="hidden" name="area_locking" value="{:I('param.area_locking')}"/>
        </if>
      		<input type="hidden" name="source" value="{$source}"/>
      		<input type="hidden" name="area_type" value="{:I('param.area_type')}"/>
	        <input type="hidden" name="dtype" value="{:I('param.dtype')}"/>
	        <input type="hidden" name="search" value="{:I('param.search')}"/>
	        <input type="hidden" name="keyword" value="{:I('param.keyword')}"/>
            <div class="pagination">{$page}</div>
            <table class="table table-hover table-bordered" width="100%">
                <thead>
                    <tr>
						<th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
                    	<th width="40">ID</th>
                        <th>店铺名称/店铺地址</th>
                        <th>设备ID/条形码</th>
                        <th>major/minor</th>
                        <th>设备类型/设备状态</th>
                        <th width="120">更新时间/激活时间</th>
                    </tr>
                </thead>
                <foreach name="devices" item="vo">
                    <tr>
                    	<td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="bid[]" value="{$vo.id}" title="ID:{$vo.id}" <if condition="$vo['locking']">disabled="true"</if>></td>
                        <td>{$vo.id}<br>{$vo['locking']==1?"已锁定":"未锁定"}</td>
                        <td>
                        	<foreach name="stores" item="st">
								<if condition="$st['store_id'] eq $vo['store_id']" >
									<a href="{:U('Asset/Store/edit', array('id'=>$st['id']))}">{$st.title}({$st.title_branch})</a>
									 - {$stype[$st['stype']]['name']}
									<br>{$st.address}
								</if>
                           </foreach>
                        </td>
                        <td>{$vo.devid}<br>{$vo.barcode}</td>
                        <td>{$vo.major}<br>{$vo.minor}</td>
                        <td>{$vo.remark}<br>{$bstatus[$vo['status']]['name']}</td>
                        <td>{$vo.updatetime}<br>{$vo.livetime}</td>
                    </tr>
                </foreach>
                <thead>
                    <tr>
						<th width="15"></th>
                    	<th width="40">ID</th>
                        <th>店铺名称/店铺地址</th>
                        <th>设备ID/条形码</th>
                        <th>major/minor</th>
                        <th>设备类型/设备状态</th>
                        <th width="120">更新时间/激活时间</th>
                    </tr>
                </thead>
            </table>
            <div class="pagination">{$page}</div>
        <div class="form-actions">
			<button class="btn btn-primary js-ajax-submit" type="submit">保存</button>
        	<button type="button" class="btn" onclick="javascript:history.go(-1);">返回</button>
		</div>
		</from>
    	<script src="__PUBLIC__/js/common.js"></script>
        </if>
        <if condition="I('param.area_type') eq 2">
			<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
		    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=ae2231ad4a1e87e1b4701c5fbc67eac9"></script>
	        <style>
	        	body,html,#mapContainer{
	        		width: 100%;
	        		height: 100%;
	        		font-size: 12px;
	        		font-family: "微软雅黑";
	        	}
        	</style>
		    <div class="row-fluid">
	            <div class="span5">
					<form action="{:U('Groups/'.$source.'_post')}" method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data">
			        <if condition="I('param.aid')">
			        	<input type="hidden" name="aid" value="{:I('param.aid')}"/>
					<else />
				        <input type="hidden" name="area_name" value="{:I('param.area_name')}"/>
				        <input type="hidden" name="area_description" value="{:I('param.area_description')}"/>
				        <input type="hidden" name="area_locking" value="{:I('param.area_locking')}"/>
			        </if>
      				<input type="hidden" name="source" value="{$source}"/>
			      	<input type="hidden" name="area_type" value="{:I('param.area_type')}"/>
	                <table class="table table-bordered">
	                    <tr>
	                        <th>点击地图获取坐标</th>
	                        <td>
	                            <input type="text" style="width:95%;" id="obtainth" placeholder="点击获得经度"/>
	                        </td>
	                        <td>
	                            <input type="text" style="width:95%;" id="obtainla" placeholder="点击获得纬度"/>
	                        </td>
	                    </tr>
	                    <tr>
	                        <th>左上角坐标</th>
	                        <td>
	                            <input type="text" style="width:95%;"  name="lt_through" required placeholder="左上角经度"/>
	                        </td>
	                        <td>
	                            <input type="text" style="width:95%;"  name="lt_latitude" required placeholder="左上角纬度"/>
	                        </td>
	                    </tr>
	                    <tr>
	                        <th>右上角坐标</th>
	                        <td>
	                            <input type="text" style="width:95%;"  name="rt_through" required placeholder="右上角经度"/>
	                        </td>
	                        <td>
	                            <input type="text" style="width:95%;"  name="rt_latitude" required placeholder="右上角纬度"/>
	                        </td>
	                    </tr>
	                    <tr>
	                        <th>左下角坐标</th>
	                        <td>
	                            <input type="text" style="width:95%;"  name="lb_through" required placeholder="左下角经度"/>
	                        </td>
	                        <td>
	                            <input type="text" style="width:95%;"  name="lb_latitude" required placeholder="左下角纬度"/>
	                        </td>
	                    </tr>
	                    <tr>
	                        <th>右下角坐标</th>
	                        <td>
	                            <input type="text" style="width:95%;"  name="rb_through" required placeholder="右下角经度"/>
	                        </td>
	                        <td>
	                            <input type="text" style="width:95%;"  name="rb_latitude" required placeholder="右下角纬度"/>
	                        </td>
	                    </tr>
	                </table>
			        <div class="form-actions">
						<button class="btn btn-primary js-ajax-submit" type="submit">保存</button>
        				<button type="button" class="btn" onclick="javascript:history.go(-1);">返回</button>
					</div>
					</form>
	            </div>
	    		<div class="span7">
					<table width="100%"  cellpadding="2" cellspacing="2" class="table table-bordered">
						<tr><td style="height:400px;">
							<div id="mapContainer"></div>
						</td></tr>
					</table>
				</div>
			</div>
           <script type="text/javascript">
        	var map = new AMap.Map("mapContainer",{
           		  zoom: 11,
                  resizeEnable: true
              });
              map.on('click', function(e) {
                  document.getElementById("obtainth").value = e.lnglat.getLng();
                  document.getElementById("obtainla").value = e.lnglat.getLat();
              });
           </script>
        </if>
        <if condition="I('param.area_type') eq 3">
		<script>
			function submit_date() {
				document.getElementById('myform').submit();
			}
		</script>
		<form method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data" action="{:U('Groups/add_device')}" id="myform">
        <if condition="I('param.aid')">
        	<input type="hidden" name="aid" value="{:I('param.aid')}"/>
		<else />
	        <input type="hidden" name="area_name" value="{:I('param.area_name')}"/>
	        <input type="hidden" name="area_description" value="{:I('param.area_description')}"/>
	        <input type="hidden" name="area_locking" value="{:I('param.area_locking')}"/>
        </if>
			<input type="hidden" name="source" value="{$source}"/>
	      	<input type="hidden" name="area_type" value="{:I('param.area_type')}"/>
	        <select name="province"onchange="submit_date();">
				<option value="0" >请选择省份</option>
				<foreach name="province" item="vo">
					<option value="{$vo.code}" <if condition="$vo['code'] eq I('param.province')">selected</if>>{$vo.name}</option>
				</foreach>
	        </select>
	        <div style="margin-top:20px;">
		        <if condition="I('param.province')">
			        <select name="city"onchange="submit_date();">
						<option value="0" >全部城市</option>
						<foreach name="city" item="vo">
							<option value="{$vo.code}" <if condition="$vo['code'] eq I('param.city')">selected</if>>{$vo.name}</option>
						</foreach>
			        </select>
		        </if>
	        </div>
		</form>
		<form action="{:U('Groups/'.$source.'_post')}" method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data">
        <if condition="I('param.aid')">
        	<input type="hidden" name="aid" value="{:I('param.aid')}"/>
		<else />
	        <input type="hidden" name="area_name" value="{:I('param.area_name')}"/>
	        <input type="hidden" name="area_description" value="{:I('param.area_description')}"/>
	        <input type="hidden" name="area_locking" value="{:I('param.area_locking')}"/>
        </if>
			<input type="hidden" name="source" value="{$source}"/>
	      	<input type="hidden" name="area_type" value="{:I('param.area_type')}"/>
	        <input type="hidden" name="province" value="{:I('param.province')}"/>
	        <input type="hidden" name="city" value="{:I('param.city')}"/>
	        <if condition="I('param.city')">
		        <select name="county">
					<option value="0" >全部区县</option>
					<foreach name="county" item="vo">
						<option value="{$vo.code}" >{$vo.name}</option>
					</foreach>
		        </select>
	        </if>
	        <div class="form-actions">
				<button class="btn btn-primary js-ajax-submit" type="submit">保存</button>
        		<button type="button" class="btn" onclick="javascript:history.go(-1);">返回</button>
			</div>
		</form>
        </if>
        <if condition="I('param.area_type') eq 4">
		<form action="{:U('Groups/'.$source.'_post')}" method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data">
        <if condition="I('param.aid')">
        	<input type="hidden" name="aid" value="{:I('param.aid')}"/>
		<else />
	        <input type="hidden" name="area_name" value="{:I('param.area_name')}"/>
	        <input type="hidden" name="area_description" value="{:I('param.area_description')}"/>
	        <input type="hidden" name="area_locking" value="{:I('param.area_locking')}"/>
        </if>
			<input type="hidden" name="source" value="{$source}"/>
	      	<input type="hidden" name="area_type" value="{:I('param.area_type')}"/>
          <table class="table table-hover table-bordered" style="word-break:break-all;">
		        <tbody>
					<tr>
		              <td>选择文件:</td>
		              <td><input type="file" name="inputcsv" accept=".csv"/>第一列必须为条形码，从第二行开始导入数据（单文件不可超过2000行记录）</td>
		           </tr>
		        </tbody>
		  </table>
        <div class="form-actions">
			<button class="btn btn-primary js-ajax-submit" type="submit">保存</button>
        	<button type="button" class="btn" onclick="javascript:history.go(-1);">返回</button>
		</div>
		</from>
        </if>
	</div>
</body>
</html>